package com.Final.hj;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.List;

public class MusicAdapter extends ArrayAdapter<MusicList.Data> {
    private int music_id;
    public MusicAdapter(Context context, int musicId, List<MusicList.Data> musicData){
        super(context, musicId, musicData);
        music_id = musicId;
    }

    @Override
    public View getView(int position, View converView, ViewGroup parent){
        //获取当前滚动实例
        MusicList.Data musicList = getItem(position);

        View view = LayoutInflater.from(getContext()).inflate(music_id, parent, false);

        TextView music_name = (TextView) view.findViewById(R.id.music_name);
        TextView music_singer = (TextView) view.findViewById(R.id.music_singer);
        TextView music_lrc = (TextView) view.findViewById(R.id.music_singer_lrc);
        ImageView music_img = (ImageView) view.findViewById(R.id.music_img);
        //设置相应的内容
        music_name.setText(musicList.getName());
        music_singer.setText(musicList.getName());
        music_lrc.setText(musicList.getName());
//      music_img.setImageResource(R.drawable.register_close);

        System.out.print("数据来了");

        Glide.with(getContext())
                .load(musicList.getPic())
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .into(music_img);
        //返回view
        return view;
    }
}
